<!DOCTYPE html>
<html lang="zh_CN">
<head>
<#--使用指令来完成引入-->
<#include "../common/header.ftl">
    <script type="application/javascript">
        $(function () {
            $(".editBtn").click(function () {
                var obj=$(this).data("json");
                if (obj){
                    $("#id").val(obj.id);
                    $("#state").val(obj.state);
                }
                //3:显示模态框
                $("#inputModal").modal("show");
            })

            $(".submitCommentBtn").click(function () {
                $("#commentForm").submit();
            })
        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">攻略评论管理</h1>
                    <input type="hidden" name="currentPage" value="1"/>
                </div>
            </div>

            <#--分页查询-->
            <form class="form-inline" id="searchForm" action="/strategyComment/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
            </form>

            <table class="table table-striped table-hover">
                <tr>
                    <th>评论者</th>
                    <th>评论时间</th>
                    <th>图片</th>
                    <th>星数</th>
                    <th>点赞数</th>
                    <th>攻略标题</th>
                    <th>内容</th>
                    <th>评论状态</th>
                    <th></th>
                </tr>
            <#--使用list指令完成迭代-->

            <#list pageInfo.list! as entity>
                <tr>
                    <td>${entity.user.nickName}</td>
                    <td>${entity.createTime?string("yyyy-MM-dd")}</td>
                    <td><img src="${entity.imgUrls}" width="80px"/></td>
                    <td>${entity.starNum}</td>
                    <td>${entity.likeNum}</td>
                    <td>${entity.strategy.title}</td>
                    <td>${entity.content}</td>
                    <td>
                        <#if entity.state==-1>
                        禁用
                        </#if>
                        <#if entity.state==0>
                        正常
                        </#if>
                        <#if entity.state==1>
                        推荐
                        </#if>
                    </td>
                    <td>
                        <a href="javascript:" class="btn btn-success btn-xs editBtn" data-json='${entity.json}'>
                            <span class="glyphicon glyphicon-pencil"></span> 设置状态
                        </a>
                    </td>
                </tr>
            </#list>
            </table>
        <#include "../common/page.ftl">
        </div>
    </div>
</div>

<!-- 修改推荐游记模态框 -->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">修改状态</h4>
            </div>
            <div class="modal-body">
                <!--填充编辑界面-->
                <form class="form-horizontal" action="/strategyComment/update.do" method="post" id="commentForm">
                    <input type="hidden" id="id" name="id"/>
                    <div class="form-group">
                        <label for="sn" class="col-lg-4 control-label">状态：</label>
                        <div class="col-lg-6">
                            <select class="form-control" id="state" name="state">
                                <option value="-1">禁用</option>
                                <option value="0">正常</option>
                                <option value="1">推荐</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitCommentBtn">保存</button>
            </div>
        </div>
    </div>
</div>

</body>
</html>